package com.report.reportserver.service.impl;

import com.report.reportserver.mapper.AuthorityMapper;
import com.report.reportserver.mapper.MenuMapper;
import com.report.reportserver.model.Menu;
import com.report.reportserver.service.PageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ ClassName: PageServiceImpl
 * @ Description：渲染用户界面菜单栏
 * @ Modified By：
 * @ Version:
 * @ Author     ：LiYing
 * @ Date       ：Created in 19:30 2022/3/10
 */
@Service
public class PageServiceImpl implements PageService {
    @Autowired
    AuthorityMapper authorityMapper;
    @Autowired
    MenuMapper menuMapper;

    @Override
    public List<Menu> queryMenuByRole(Integer role) {
        List<Integer> ids = authorityMapper.selectByRoleId(role);
        List<Menu> list = new ArrayList<>();
        for (Integer id : ids) {
            list.add(menuMapper.selectByPrimaryKey(id));
        }
        return list;
    }
}
